<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>添加员工页面</title>
</head>
<body>
<!-- 1、自己手动写HTML页面 -->
<!--        <h3>添加员工</h3>
<form action="" method="POST">
    {% csrf_token %}
    <p>姓名: <input type="text" name="name" value="zhangsan"></p>
    <p>年龄: <input type="text" name="age" value="22"></p>
    <p>工资: <input type="text" name="salary" value="10000"></p>
    <input type="submit">
</form> -->

<!-- 2、通过form对象的as_p方法实现 -->
<!--        <form action="" method="post" novalidate>
    {% csrf_token %}
    {{ form.as_p }}
    <input type="submit">
</form> -->

<!-- 3、手动获取form对象的字段 -->
<!--       <form action="" method="post" novalidate>
    {% csrf_token %}
    <div>
        <label for="id_{{ form.name.name }}">姓名</label>
        {{ form.name }} <span>{{ form.name.errors.0 }}</span>
    </div>
    <div>
        <label for="id_{{ form.age.name }}">年龄</label>
        {{ form.age }} <span>{{ form.age.errors.0 }}</span>
    </div>
    <div>
        <label for="id_salary">工资</label>
        {{ form.salary }} <span>{{ form.salary.errors.0 }}</span>
    </div>
    <input type="submit">
</form>
-->

<!-- 4、用for循环展示所有字段 -->
<!--       <form action="" method="post" novalidate>
    {% csrf_token %}
    {% for field in form %}
    <div>
        <label for="id_{{ field.name }}">{{ field.label }}</label>
        {{ field }} <span>{{ field.errors.0 }}</span>
    </div>
    {% endfor %}
    <input type="submit">
</form> -->
<form action="" method="POST" novalidate>
    {% csrf_token %}
    <div>
        <label for="id_{{ form.name.name }}">姓名</label>
        <br/>
        {{ form.name }} <span>{{ form.name.errors.0 }}</span>
    </div>

    <div>
        <label for="id_{{ form.age.name }}">年龄</label>
        {{ form.age }} <span>{{ form.age.errors.0 }}</span>
    </div>
    <div>
        <label for="id_salary">工资</label>
        {{ form.salary }} <span>{{ form.salary.errors.0 }}{{ clear_errors.0 }}</span>
    </div>
    <div>
        <label for="id_r_salary">请再输入工资</label>
        {{ form.r_salary }} <span>{{ form.r_salary.errors.0 }}{{ clear_errors.0 }}</span>
    </div>
    <input type="submit">
</form>

<!--       <form action="" method="post" novalidate>
    {% csrf_token %}
    {% for field in form %}
    <div>
        <label for="">{{ field.label }}</label>
        {{ field }} <span>{{ field.errors.0 }}</span>
    </div>
    {% endfor %}
    <input type="submit">
</form> -->
</body>
</html>
